import Vue from 'vue'
import Router from 'vue-router'
// 导入刚才编写的组件
import Home from '@/components/home/Home'
import Login from '@/components/Login'
import Index from '../components/Index'
import LibraryIndex from '../components/library/LibraryIndex'

Vue.use(Router)

export default new Router({
    mode: 'history',
    routes: [
        {
            path: '/',
            redirect: '/login'
        },
        // 下面都是固定的写法
        {
            path: '/login',
            name: 'Login',
            component: Login
        },
        {
            path: '/index',
            name: 'Index',
            component: Index,
            redirect:'/home',
            children:[
                {
                    path: '/home',
                    name: 'Home',
                    component: Home,
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/library',
                    name: 'Library',
                    component: LibraryIndex,
                    meta: {
                        requireAuth: true
                    }
                }
            ]
        }
    ]
})

